package com.awphone.tools.init;

import com.awphone.data.User;
import com.awphone.utils.PasswordUtils;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 * @author a_polyakov
 * Date: 05.03.13
 * Time: 1:30
 * Init
 */
public class InitAll {
    public static void main(String args[]) {
        EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("AWPhone");
        EntityManager em = entityManagerFactory.createEntityManager();
        em.getTransaction().begin();

        User user = new User("Alex", "alex@awphone.com", PasswordUtils.sha2("1"), true, false);
        em.persist(user);

        em.getTransaction().commit();
        em.close();
        entityManagerFactory.close();
    }
}
